package com.atguigu.lease.common.GlobalExceptionHandler;


import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Data;

/**
 * 自定义异常类
 */
@Data
public class CustomException extends RuntimeException {
    
    /**
     * 错误码
     */
    private Integer code;
    
    /**
     * 错误消息
     */
    private String message;
    
    /**
     * 构造函数，使用枚举类型
     * @param resultCodeEnum 结果码枚举
     */
    public CustomException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
    }
    
    /**
     * 构造函数，自定义错误信息
     * @param resultCodeEnum 结果码枚举
     * @param message 自定义错误信息
     */
    public CustomException(ResultCodeEnum resultCodeEnum, String message) {
        super(message);
        this.code = resultCodeEnum.getCode();
        this.message = message;
    }
}